import { createRouter, createWebHistory } from 'vue-router'
//import { useUserStore } from "@/stores/category.js";
import Login from '@/views/Login/LoginPage.vue'
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
import Category from '@/views/Category/index.vue'
import SubCategory from '@/views/SubCategory/subindex.vue'
// createRouter 创建路由实例
// 配置 history 模式
// 1. history模式：createWebHistory     地址栏不带 #
// 2. hash模式：   createWebHashHistory 地址栏带 #
// console.log(import.meta.env.DEV)

// vite 中的环境变量 import.meta.env.BASE_URL  就是 vite.config.js 中的 base 配置项
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),  // 配置路由模式    import.meta.env.BASE_URL 是基地址路径
  routes: [
    {
      path: '/',
      component: Layout,
      // component: () => import('@/views/layout/LayoutContainer.vue'),
      // redirect: '/article/manage',
      children: [
        { path: '', component: Home },
        // { path: 'category', component: Category }
        // { path: '', component: () => import('@/views/Home/index.vue')},
        { path: 'category/:id', component: () => import('@/views/Category/index.vue')},
        { path: 'category/sub/:id', component: () => import('@/views/SubCategory/subindex.vue')},
        { path: 'detail/:id', component: () => import('@/views/Detail/Detailindex.vue')},

      ]
    },
    //{ path: '/login', component: Login }
    { path: '/login', component: () => import('@/views/Login/LoginPage.vue')},
  ],
  // 路由滚动行为定制
  scrollBehavior() {
    return {
      top: 0
    }
  }
})

export default router
